<%--
  Created by IntelliJ IDEA.
  User: mao
  Date: 2021/8/10
  Time: 14:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <TITLE>爱家租房 - 用户注册</TITLE>
    <META content="text/html; charset=utf-8" http-equiv=Content-Type>
    <LINK
            rel=stylesheet type=text/css href="/css/style.css">
    <META name=GENERATOR content="MSHTML 8.00.7601.17514">
</HEAD>
<BODY>
<DIV id=header class=wrap>
    <DIV id=logo><IMG src="../images/logo.gif"></DIV>
</DIV>
<DIV id=regLogin class=wrap>
    <DIV class=dialog>
        <DL class=clearfix>
            <DT>新用户注册</DT>
            <DD class=past>填写个人信息</DD>
        </DL>
        <DIV class=box>
            <FORM onsubmit="soScr()" action="/users/reg.do">
                <DIV class=infos>
                    <TABLE class=field>
                        <TBODY>
                        <TR>
                            <TD class=field>用 户 名：</TD>
                            <TD><INPUT onchange="jy(this.value)" class=text type=text name=name required><span
                                    id="jy"></span></TD>
                        </TR>
                        <TR>
                            <TD class=field>密　　码：</TD>
                            <TD><INPUT class=text onclick="dianji()" type=password name=password required></TD>
                        </TR>
                        <TR>
                            <TD class=field>确认密码：</TD>
                            <TD><INPUT class=text onchange="jymm(this.value)" type=password name=repassword
                                       required><span id="jymm"></span></TD>
                        </TR>
                        <TR>
                            <TD class=field>电　　话：</TD>
                            <TD><INPUT class=text type=text name=telephone required></TD>
                        </TR>
                        <TR>
                            <TD class=field>用户姓名：</TD>
                            <TD><INPUT class=text type=text name=username required></TD>
                        </TR>
                        </TBODY>
                    </TABLE>
                    <DIV class=buttons>
                        <INPUT value=立即注册 type=submit>
                    </DIV>
                </DIV>
            </FORM>
        </DIV>
    </DIV>
</DIV>
<DIV id=footer class=wrap>
    <DL>
        <DT>爱家租房 © 2010 北大爱家 京ICP证1000001号</DT>
        <DD>关于我们 · 联系方式 · 意见反馈 · 帮助中心</DD>
    </DL>
</DIV>

<script src="/scripts/jquery-3.3.1.min.js"></script>
<script>
    var fal1 = false
    var fal2 = false

    function jy(a) {
        if (a == null || a == "") {
            $("#jy").html("账号不能为空")
            $("#jy").css("color", "red")
            fal1 = false
            return
        }
        $.post("users/jy", {"name": a}, function (data) {
            if (data == 'true') {

                $("#jy").html("账号可以使用")
                $("#jy").css("color", "green")
                fal1 = true;
            } else {

                $("#jy").html("账号重复")
                $("#jy").css("color", "red")
                fal1 = false
            }
        })
    }

    function dianji() {
        $("input[type='password']").val("")
    }

    function jymm(a) {
        if (a == null || a == "") {
            $("#jymm").html("不能为空")
            $("#jymm").css("color", "red")
            fal2 = false
            return

        }
        if ($("input[name='password']").val() == $("input[name='repassword']").val()) {
            $("#jymm").html("密码可以使用")
            $("#jymm").css("color", "green")
            fal2 = true
        } else {
            $("#jymm").html("两次密码不同")
            $("#jymm").css("color", "red")
            fal2 = false
        }

    }

    function soScr() {
        if(fal1 && fal2){
            return true
        }
        return false
    }
</script>
</BODY>
</HTML>